<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title></title>
    <script type="text/javascript">
        window.onload = function() {

            // 第一步：获取所有的超链接
            var aArraysObj = document.getElementsByTagName("a");

            for (var i = 0; i < aArraysObj.length; i++) {

                // 获取每一个超链接
                var aObj = aArraysObj[i];

                aObj.onclick = function() {
                    alert("你点击了我");
                }
            }
        }
    </script>

</head>

<body>
    <a href="#">点击1</a><br/>
    <a href="#">点击2</a><br/>
    <a href="#">点击3</a><br/>
    <a href="#">点击4</a><br/>
</body>

</html>